import type { TableColumn } from '@/components/core/dynamic-table';

export type TableListItem = API.UserListPageResultItem;
export type TableColumnItem = TableColumn<TableListItem>;

const operationParams = [
  {
    label: '使用中',
    value: 1,
  },
  {
    label: '维修中',
    value: 2,
  },
  {
    label: '维保中',
    value: 3,
  },
  {
    label: '点检中',
    value: 4,
  },
  {
    label: '停用',
    value: 5,
  },
];
const operationParams2 = [
  {
    label: '监测设备',
    value: 1,
  },
  {
    label: '分析仪器',
    value: 2,
  },
];

export const baseColumns: TableColumn[] = [
  {
    title: '关键字',
    align: 'left',
    dataIndex: 'keyword',
    hideInTable: true,
    formItemProps: {
      labelWidth: 55,
      componentProps: () => {
        return {
          placeholder: '可输入设备编号、名称、型号搜索',
          disabledLabelWidth: true,
        };
      },
    },
  },
  {
    title: '设备类型',
    align: 'left',
    dataIndex: 'type2',
    hideInTable: true,
    formItemProps: {
      component: 'Select',
      componentProps: {
        options: operationParams2,
      },
    },
  },
  {
    title: '设备编号',
    align: 'left',
    dataIndex: 'userNum',
    hideInSearch: true,
  },
  {
    title: '设备名称',
    align: 'left',
    dataIndex: 'userLogin',
    hideInSearch: true,
  },
  {
    title: '设备类型',
    align: 'left',
    dataIndex: 'userName',
    hideInSearch: true,
  },
  {
    title: '设备状态',
    align: 'left',
    dataIndex: 'type',
    formItemProps: {
      component: 'Select',
      componentProps: {
        options: operationParams,
      },
    },
    customRender: ({ record }) =>
      operationParams.filter((item) => item.value == record.type)[0].label,
  },
  {
    title: '设备型号',
    align: 'left',
    dataIndex: 'action',
    hideInSearch: true,
  },
  {
    title: '所在部门',
    align: 'left',
    dataIndex: 'operationTime',
    hideInSearch: true,
  },
];

export const baseColumns2: TableColumn[] = [
  {
    title: '关键字',
    align: 'left',
    dataIndex: 'keyword',
    hideInTable: true,
    formItemProps: {
      labelWidth: 55,
      componentProps: () => {
        return {
          placeholder: '可输入设备编号、名称、型号搜索',
          disabledLabelWidth: true,
        };
      },
    },
  },
  {
    title: '设备类型',
    align: 'left',
    dataIndex: 'type2',
    hideInTable: true,
    formItemProps: {
      component: 'Select',
      componentProps: {
        options: operationParams2,
      },
    },
  },
  {
    title: '设备编号',
    align: 'left',
    dataIndex: 'userNum',
    hideInSearch: true,
  },
  {
    title: '设备名称',
    align: 'left',
    dataIndex: 'userLogin',
    hideInSearch: true,
  },
  {
    title: '设备类型',
    align: 'left',
    dataIndex: 'userName',
    hideInSearch: true,
  },
  {
    title: '设备状态',
    align: 'left',
    dataIndex: 'type',
    formItemProps: {
      component: 'Select',
      componentProps: {
        options: operationParams,
      },
    },
    customRender: ({ record }) =>
      operationParams.filter((item) => item.value == record.type)[0].label,
  },
  {
    title: '设备型号',
    align: 'left',
    dataIndex: 'action',
    hideInSearch: true,
  },
  {
    title: '所在部门',
    align: 'left',
    dataIndex: 'operationTime',
    hideInSearch: true,
  },
];
